package com.whpost.admin.controller.stamp.h5;

import jakarta.servlet.http.HttpServletRequest;
import org.springframework.stereotype.Controller;
import org.springframework.ui.Model;
import org.springframework.web.bind.annotation.RequestMapping;

import java.io.UnsupportedEncodingException;
import java.nio.charset.Charset;


/**
 * @author Yinzhuoyi
 * @date 2020/5/13 9:52
 */
@Controller
@RequestMapping("/h5")
public class Login {

    @RequestMapping(value ="/login")
    public String Login(Model model, String backurl) throws UnsupportedEncodingException {
        model.addAttribute("backurl",backurl.replaceAll("\\$", "&"));
        return "stamp/h5/login";
    }

    @RequestMapping(value ="/login_do")
    public String login_do(Model model, HttpServletRequest request) throws UnsupportedEncodingException {
        String code=(String)request.getParameter("code");
        String backUrl=(String)request.getParameter("backUrl");
        String state=(String)request.getParameter("state");

        model.addAttribute("backUrl",backUrl);
        model.addAttribute("code",code);
        model.addAttribute("state",state);
        return "stamp/h5/login_do";
    }

    @RequestMapping(value ="/login_test")
    public String LoginTest() {
        return "stamp/h5/login_test";
    }
}
